﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace RenChangYou.BLL
{
    public partial class DY_Comment
    {
        private readonly RenChangYou.DAL.DY_Comment dal = new RenChangYou.DAL.DY_Comment();
        public DY_Comment()
        { 
            
        }

        public static string GetRankDescription(int rank)
        {
            if (rank == 1) return "不满意";
            else if (rank == 2) return "一般";
            else if (rank == 3) return "合格";
            else if (rank == 4) return "良好";
            else if (rank == 5) return "很满意";
            else return string.Empty;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RenChangYou.Model.DY_Comment model)
        {
            return dal.Add(model);
        }


        public List<RenChangYou.Model.DY_Comment> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<RenChangYou.Model.DY_Comment> DataTableToList(DataTable dt)
        {
            List<RenChangYou.Model.DY_Comment> modelList = new List<RenChangYou.Model.DY_Comment>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                RenChangYou.Model.DY_Comment model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
